from app.lib.model import Model
from tortoise import fields


class Comment(Model):
    class Meta:
        table = "Comment"

    auto_id = fields.IntField(pk=True)
    article = fields.ForeignKeyField("models.Article", related_name="comments")
    content = fields.TextField()
    images = fields.JSONField()
    parent_id = fields.CharField(max_length=36, default="", description="父评论id")
    likes = fields.ManyToManyField(
        "models.User",
        through="UserLikeComment",
        related_name="liked_comments",
        forward_key="user_id",
        backward_key="comment_id",
    )
    is_deleted = fields.BooleanField(default=False)
